import request from "@/axios";

export function getUserInfo(){
    return request({
        url: '/sys/userInfo',
        method: 'get'
    })
}

export function logout(){
    return request({
        url: '/logout',
        method: 'post'
    })
}

export function updatePass(data){
    return request({
        url: '/sys/user/updatePass',
        method: 'post',
        data
    })
}

export function getUserList(username, current, size){
    return request({
        url: '/sys/user/list',
        method: 'get',
        params: {
            username,
            current,
            size
        }
    })
}

export function getRoleList(){
    return request({
        url: '/sys/role/list',
        method: 'get'
    })
}

export function updateOrSaveUser(data){
    return request({
        url: data.id ? '/sys/user/update' : '/sys/user/save',
        method: 'post',
        data
    })
}

export function getUserInfoById(id){
    return request({
        url: '/sys/user/info/' + id,
        method: 'get'
    })
}

export function deleteUserByIds(data){
    return request({
        url: '/sys/user/delete',
        method: 'post',
        data
    })
}

export function rolePerm(id, data){
    return request({
        url: '/sys/user/role/${id}',
        method: 'post',
        data
    })
}

export function rePass(data){
    return request({
        url: '/sys/user/repass',
        method: 'post',
        data
    })
}

export function getMenuList(){
    return request({
        url: '/sys/menu/list',
        method: 'get'
    })
}

export function getRoleListByCondition(name, current, size){
    return request({
        url: '/sys/role/list',
        method: 'get',
        params: {
            name,
            current,
            size
        }
    })
}

export function updateOrSaveRole(data){
    return request({
        url: data.id ? '/sys/role/update' : '/sys/role/save',
        method: 'post',
        data
    })
}

export function getRoleInfoById(id){
    return request({
        url: '/sys/role/info/' + id,
        method: 'get'
    })
}

export function deleteRoleByIds(data){
    return request({
        url: '/sys/role/delete',
        method: 'post',
        data
    })
}

export function menuPerm(id, data){
    return request({
        url: '/sys/role/perm/${id}',
        method: 'post',
        data
    })
}

export function updateOrSaveMenu(data){
    return request({
        url: data.id ? '/sys/menu/update' : '/sys/menu/save',
        method: 'post',
        data
    })
}

export function getMenuInfoById(id){
    return request({
        url: '/sys/menu/info/' + id,
        method: 'get'
    })
}

export function deleteMenuById(id){
    return request({
        url: 'sys/menu/delete/' + id,
        method: 'post',
    })
}

